package view{
	import flash.display.Graphics;
	import flash.display.Sprite;
	/**
	 * 建筑物进度条 
	 * @author 1
	 * 
	 */	
	public class RectBar extends Sprite{
		/**
		 * 进度条边框 
		 */		
		private var rectBorder:Sprite;
		/**
		 * 进度条显示矩形 
		 */		
		private var rect:Sprite;
		/**
		 * 设定宽度 
		 */		
		private var rectWidth:Number=0;
		/**
		 * 设定高度 
		 */		
		private var rectHeight:Number=0;
		
		/**
		 * 为进度条显示矩形设置get/set方法,通过宽度重绘进度 
		 */		
		private var _reWidth:Number;
		public function RectBar(_rectWidth:Number=57,_rectHeight:Number=10){
			rectWidth = _rectWidth;
			rectHeight = _rectHeight;
			rectBorder = new Sprite();
			addChild(rectBorder);
			rect = new Sprite();
			addChild(rect);
			drawRectBorder();
		}
		private function drawRectBorder():void{
			var g:Graphics = rectBorder.graphics;
			g.lineStyle(1,0xff6600);
			g.drawRect(0,0,rectWidth,rectHeight);
			g.endFill();
		}

		public function get reWidth():Number{
			return _reWidth;
		}

		public function set reWidth(value:Number):void{
			_reWidth = value;
			drawRect(reWidth);
		}
		
		private function drawRect(reWidth:Number):void{
			var g:Graphics = rect.graphics;
			g.clear();
			g.beginFill(0xff9900,1);
			g.drawRect(1,1,reWidth,rectHeight-2);
			g.endFill();
		}
		
	}
}